# Maintainer: Angel Velasquez <angvp@archlinux.org>
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Douglas Soares de Andrade <douglas@archlinux.org>
# Contributor: Mario Danic <mario.danic@gmail.com>

pkgname=python-paramiko
pkgver=2.11.1
pkgrel=4
pkgdesc="Python module that implements the SSH2 protocol"
url="https://github.com/paramiko/paramiko/"
license=('LGPL')
arch=('any')
depends=('python-bcrypt' 'python-cryptography' 'python-pynacl')
makedepends=('python-setuptools' 'python-bcrypt' 'python-cryptography' 'python-pynacl')
checkdepends=('python-pytest-relaxed' 'python-pyasn1' 'python-invoke')
source=(
  "https://github.com/paramiko/paramiko/archive/$pkgver/$pkgname-$pkgver.tar.gz"
  'paramiko-unittest_mock.patch::https://github.com/paramiko/paramiko/commit/8bda24dcb4bc8ca0969e78b3cced9bf82c010343.patch'
)
sha512sums=('7cf3f9124fcdd5df2f132bec213be60fe2e78a95eee80e0a4388459d22907d2c23dbf4cc7ae7bfc9575f392aacad5b3d3a32955b662a0804999e24b922269bc5'
            'dc43a2a2f8d35699620f264a26c2f2bbda60e9e8ba139d58750a5897c4c297417eabeaffbb28810c4f6a67561bb1398bc8b5266e0416e29fcf3c704b78df47ba')

prepare() {
  cd paramiko-$pkgver
  patch --forward --strip=1 --input=../paramiko-unittest_mock.patch
}

check() {
  cd paramiko-$pkgver
  LANG=en_US.UTF-8 pytest
}

package() {
  cd paramiko-$pkgver

  python setup.py install --root="$pkgdir" --optimize=1
  install -dm755 "$pkgdir"/usr/share/doc/$pkgname/demos
  install -m644 demos/* "$pkgdir"/usr/share/doc/$pkgname/demos
  chmod 755 "$pkgdir"/usr/share/doc/$pkgname/demos/*.py
}
